<?php

namespace App\Http\Controllers\Teaching;

use App\Common\Utils\JsonResponse;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class DisciplineController extends Controller
{
    /** @var \App\Services\System\LogService $logService */
    private $logService;
    /** @var \App\Services\Teaching\TeachingSubjectService $teachingSubjectService */
    private $teachingSubjectService;

    /**
    * Create a new controller instance.
    *
    * @return void
    */
    public function __construct()
    {
        parent::__construct();
        $this->middleware('auth');
        $this->logService = app('logService');
        $this->teachingSubjectService = app('teachingSubjectService');
    }

    /**
     * @Description: 获取任教学科列表信息数据
     * @Author: kzj
     * @datetime: 2023-02-21
     */
    public function getList(Request $request)
    {
        try
        {
            $result = $this->teachingSubjectService->getList($request->all());
            $this->logService->log('209', '任教学科列表信息数据查看', '任教学科列表信息数据查看');
            return JsonResponse::get($result['data'], TRUE, $result['total'], $result['per_page']);
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }

    /**
     * @Description: 任教学科添加
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function add(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->add($request->all());
            $this->logService->log('210', '任教学科添加', '任教学科添加');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /*
     * @Description: 任教学科导入
     * @Author:  Kzj
     * @Date: 2023-11-14 09:40:16
     */
    public function import(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->import($request->all());
            $this->logService->log('331', '任教学科导入', '任教学科导入');
            return JsonResponse::success($result,'导入成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 任教学科单条数据
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function one(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->one($request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 任教学科编辑
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function edit(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->edit($request->all());
            $this->logService->log('211', '任教学科编辑', '任教学科编辑');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 任教学科审核
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function check(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->check($request->all());
            $this->logService->log('212', '任教学科审核', '任教学科审核');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 任教学科删除
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function del(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->del($request->all());
            $this->logService->log('213', '任教学科删除', '任教学科删除');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /*
     * @Description: 任教学科导出
     * @Author:  Kzj
     * @Date: 2023-11-17 14:43:04
     */
    public function export(Request $request)
    {
        try{
            $result = $this->teachingSubjectService->export($request->all());
            $this->logService->log('337', '任教学科导出', '任教学科导出');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }
}
